package com.usian.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usian.dao.Empdao;
import com.usian.pojo.Emp;
import com.usian.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    Empdao empdao;

    public User getUser(Integer id) {
        return new User(id,"123",18);
    }

    public List<Emp> findall() {
        return empdao.findAll();
    }

    public Emp findempbyeid(Integer eid) {

        Emp emp = empdao.selectOne(new QueryWrapper<Emp>().eq("eid",eid));
        /*Emp emp = new Emp();
        emp.setEid(eid);
        emp.setAge("18");*/
        return emp;
    }

    public List<Emp> findempbyename(String ename) {
        QueryWrapper<Emp> empQueryWrapper = new QueryWrapper<>();
        empQueryWrapper.like("ename",ename);
        return empdao.selectList(empQueryWrapper);
    }
}
